package com.cristina.attention.handler.impl;

import com.cristina.attention.domain.MessageInfo;
import com.cristina.attention.handler.ImHandler;
import com.cristina.attention.service.MessageService;
import com.cristina.attention.utils.enums.ChannelType;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 私聊消息同步
 * 用户发送消息(websocket) -> communication(netty) -> support(消息队列) ->(feign) web(业务)
 * 不排除在这四个步骤中出现异常. 出现异常消息如何处理?
 *
 * @author by superman
 */
@Component
public class SingleChatHandler extends ImHandler {

    @Resource
    private MessageService messageService;

    public SingleChatHandler() {
        channelCode = ChannelType.IM_CHAT.getCode();
    }

    @Override
    public void handler(MessageInfo taskInfo) {
        messageService.syncSimpleMessageRecord(taskInfo.getMsgContext());
    }
}
